import React, { Component } from 'react'
import events from '@/utils/EventBus'
export default class A extends Component {
  constructor(){
    super()
    this.state={
      msg:''
    }
  }
  getMsg=(arg)=>{
    console.log('arg',arg);
    this.setState({msg:arg})
  }
  componentDidMount(){
    events.addListener('send',this.getMsg)
  }
  componentWillUnmount(){
    events.removeListener('send',this.getMsg)
  }
  render() {
    const {msg}=this.state
    return (
      <div style={{width:'200px',height:'200px',backgroundColor:'red'}}>{msg}</div>
    )
  }
}
